<?php
include_once './aliyun-dyapi/Sms.php';
session_start();
$time = isset($_SESSION['time'])?$_SESSION['time']:0;
if(time() - $time < 60){
    echo json_encode(['code'=>403,'message'=>'请勿频繁请求']);
}else{
    $phone = isset($_GET['phone']) ? $_GET['phone'] : '';
    $code = isset($_GET['code']) ? $_GET['code'] : '';
    if(!$phone || !$code){
        echo json_encode(['code'=>400,'message'=>'参数异常']);
    }else {
    $obj = new Sms('LTAI5tRpA13MUrFVmbvthSMs','5MD7KNXIBIEO10NDUxncqPVYJSdfb8');
    $result = $obj->sendSms('荣钧健康饮水','SMS_223587547',$phone,['code'=>$code]);
    $_SESSION['time'] = time();
    echo json_encode($result);
    }
}